//
//  NSDate+HBUtilites.h
//  HBActionSheet
//
//  Created by 韩冰 on 2017/10/25.
//  Copyright © 2017年 韩冰. All rights reserved.
//

#import <Foundation/Foundation.h>

#define D_MINUTE 60
#define D_HOUR 3600
#define D_DAY 86400
#define D_WEEK 604800
#define D_YEAR 31556926

@interface NSDate (HBUtilites)

// Decomposing dates
@property (readonly) NSInteger nearestHour;
@property (readonly) NSInteger hour;
@property (readonly) NSInteger minute;
@property (readonly) NSInteger seconds;
@property (readonly) NSInteger day;
@property (readonly) NSInteger month;
@property (readonly) NSInteger week;
@property (readonly) NSInteger weekday;
@property (readonly) NSInteger nthWeekday; // e.g. 2nd Tuesday of the month == 2
@property (readonly) NSInteger year;

// Comparing dates
- (BOOL)isEqualToDateIgnoringTime:(NSDate *)aDate;
- (BOOL)isToday;
- (BOOL)isTomorrow;
- (BOOL)isYesterday;
- (BOOL)isTheDayBeforeYesterday;
- (BOOL)isSameWeekAsDate:(NSDate *)aDate;
- (BOOL)isThisWeek;
- (BOOL)isNextWeek;
- (BOOL)isLastWeek;
- (BOOL)isSameMonthAsDate:(NSDate *)aDate;
- (BOOL)isThisMonth;
- (BOOL)isSameYearAsDate:(NSDate *)aDate;
- (BOOL)isThisYear;
- (BOOL)isNextYear;
- (BOOL)isLastYear;
- (BOOL)isEarlierThanDate:(NSDate *)aDate;
- (BOOL)isLaterThanDate:(NSDate *)aDate;
- (BOOL)isInFuture;
- (BOOL)isInPast;



// Adjusting dates
- (NSDate *)dateByAddingDays:(NSInteger)dDays;
- (NSDate *)dateBySubtractingDays:(NSInteger)dDays;
- (NSDate *)dateByAddingHours:(NSInteger)dHours;
- (NSDate *)dateBySubtractingHours:(NSInteger)dHours;
- (NSDate *)dateByAddingMinutes:(NSInteger)dMinutes;
- (NSDate *)dateBySubtractingMinutes:(NSInteger)dMinutes;
- (NSDate *)dateAtStartOfDay;

// Retrieving intervals
- (NSInteger)minutesAfterDate:(NSDate *)aDate;
- (NSInteger)minutesBeforeDate:(NSDate *)aDate;
- (NSInteger)hoursAfterDate:(NSDate *)aDate;
- (NSInteger)hoursBeforeDate:(NSDate *)aDate;
- (NSInteger)daysAfterDate:(NSDate *)aDate;
- (NSInteger)daysBeforeDate:(NSDate *)aDate;
- (NSInteger)distanceInDaysToDate:(NSDate *)anotherDate;

- (NSString *)distanceToDate:(NSDate *)anotherDate;

- (NSInteger)distanceUseChineseLocalInHoursToDate:(NSDate *)anotherDate;
- (NSInteger)distanceUseChineseLocalInDaysToDate:(NSDate *)anotherDate;

//Date TimeZone
- (NSDate *)toLocalTimeFromSourceTZ:(NSTimeZone *)tm;
- (NSDate *)beiJingToLocalTime;
// Date roles
- (BOOL)isTypicallyWorkday;

- (BOOL)isTypicallyWeekend;
// Relative dates from the current date
+ (NSDate *)dateTomorrow;

+ (NSDate *)dateYesterday;

+ (NSDate *)dateWithDaysFromNow:(NSInteger)days;

+ (NSDate *)dateWithDaysBeforeNow:(NSInteger)days;

+ (NSDate *)dateWithHoursFromNow:(NSInteger)dHours;

+ (NSDate *)dateWithHoursBeforeNow:(NSInteger)dHours;

+ (NSDate *)dateWithMinutesFromNow:(NSInteger)dMinutes;

+ (NSDate *)dateWithMinutesBeforeNow:(NSInteger)dMinutes;
/**
 获取过去时间到特定时间的差
 
 @param fromDate 起始
 @param toDate 结束
 @return 刚刚，几天前，等等
 */
+ (NSString *)getDateDifFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate;

// 距离toDate还差多少秒
+ (NSString *)getDateSecondToData:(NSDate *)toDate;
@end
